package com.flyfinger.codec;

import com.flyfinger.codec.impl.JSONSerializer;
import com.flyfinger.pojo.RpcRequest;
import io.netty.channel.embedded.EmbeddedChannel;

/**
 * @author zhouyp
 * @program code
 * @description
 * @create 2020-06-14
 */
public class DecodeAndEncodeTest {

	public static void main(String[] args) {
		final Serializer serializer = JSONSerializer.getInstance();
		// given
		EmbeddedChannel channel = new EmbeddedChannel(
				new RpcEncoder(serializer), new RpcDecoder(serializer));
		// when
		RpcRequest msg = new RpcRequest();

		channel.writeOutbound(msg);

		final Object o = channel.readOutbound();
		System.out.println(o);
		channel.writeInbound(o);
		// then
		RpcRequest returnedFoo = channel.readInbound();
		System.out.println(returnedFoo);

	}
}
